package com.jk.mapper;

import com.jk.entity.BankCard;
import com.jk.entity.Payment;

import com.jk.entity.TransferRecord;
import com.jk.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface PaymentMapper {
    /**
     * 查询余额数据
     * @param userId
     * @return
     */
    @Select("select pa.accountBalance from payment_account pa where pa.userId = #{userId}")
    public Payment queryPayment(String userId);

    /**
     * 新增数据
     * @param payment
     */
    @Insert("insert into payment_account values (#{accountId},#{paymentType},#{accountBalance},#{belongsBank},#{paymentPassword},#{userId},#{bankNumber}) ")

    public void addPayment(Payment payment);

    /**
     * 删除数据
     * @param accountId
     * @return
     */
    @Delete("delete from payment_account where accountId = #{accountId}")

    public void deletePayment(String accountId);
    /**充值（修改余额宝余额）[将账户余额转入余额宝余额  (余额宝 +)  ]*/
    @Update("update yu_ebao yu set yu.existingYue = yu.existingYue + #{paymentInto} where yu.userId = #{userId}")
    void updateYuebao(@Param("userId") String userId, @Param("paymentInto") double paymentInto);
    /**充值（修改账户余额） [将账户余额转入余额宝余额  (账户余额 -)  ]*/
    @Update("update payment_account pt set pt.accountBalance = pt.accountBalance - #{paymentInto} where pt.userId = #{userId}")
    void updateZhyue(@Param("userId") String userId,@Param("paymentInto") double paymentInto);

    /**提现（修改银行卡余额）[将账户余额充值到银行卡余额  (银行卡 +)  ]*/
    @Update("update payment_account pa set pa.accountBalance = pa.accountBalance - #{paymentInto} where pa.userId = #{userId}")
    void updateBankOut(@Param("userId") String userId,@Param("paymentInto") double paymentInto);
    /**提现（修改账户余额） [将账户余额转入银行卡余额  (账户余额 -)  ]*/
    @Update("update bankCard bc set bc.bankBalance = bc.bankBalance + #{paymentInto} where bc.userId = #{userId}")
    void updateBankRoll(@Param("userId") String userId,@Param("paymentInto") double paymentInto);
    /**充值（修改银行卡余额）[将账户银行卡转入余额  (余额 +)  ]*/
    @Update("update payment_account pa set pa.accountBalance = pa.accountBalance + #{paymentInto} where pa.userId = #{userId}")
    void updateBankYue(@Param("userId") String userId,@Param("paymentInto") double paymentInto);
    /**充值（修改账户余额） [将银行卡余额转入余额  (银行卡余额 -)  ]*/
    @Update("update bankCard bc set bc.bankBalance = bc.bankBalance - #{paymentInto} where bc.userId = #{userId}")
    void updateBankZhyue(@Param("userId") String userId,@Param("paymentInto") double paymentInto);
    /**添加转账记录*/
    @Insert("insert into transfer_record values(#{id},#{recordName},#{dealMoney},#{dealStatus},#{dealDate},#{userId})")
    void addPaymentRecord(TransferRecord tr);
    /**查询银行卡卡号*/
    @Select("select b.bankNum from bankcard b where b.userId = #{userId}")
    BankCard queryBankId(String userId);
    /**
     * 查询银行卡余额数据
     * @param userId
     * @return
     */
    @Select("select b.bankBalance from bankcard b where b.userId = #{userId}")
    BankCard queryBank(String userId);
    /**查询手机号码*/
    /*@Select("select b.bankNum from bankcard b where b.userId = #{userId}")
    User queryPhoneNumber(String userId);*/
}
